package com.lyl.servicelive.controller;


import com.lyl.commonutils.R;
import com.lyl.servicelive.entity.vo.LiveCourseConfigVo;
import com.lyl.servicelive.service.CourseConfigService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 直播课程配置表 前端控制器
 * </p>
 *
 * @author 雷艳玲
 * @since 2022-07-05
 */
@RestController
@RequestMapping("/servicelive/courseconfig")
public class CourseConfigController {

    @Autowired
    CourseConfigService configService;


    @ApiOperation(value = "获取配置信息")
    @GetMapping("getCourseConfig/{id}")
    public R getCourseConfig(@PathVariable Long id) {
        //获取配置
        LiveCourseConfigVo courseConfigVo=  configService.getCourseConfig(id);
        return R.ok().data("courseConfig",courseConfigVo);
    }

    @ApiOperation(value = "修改配置")
    @PutMapping("updateConfig")
    public R updateConfig(@RequestBody LiveCourseConfigVo liveCourseConfigVo) {

      if(  configService.updateConfig(liveCourseConfigVo)){
            return R.ok().message("修改成功");
        }else{
          return R.error().message("修改失败");
      }
    }
}

